package com.kuang.service;

import com.kuang.dao.BookMapper;
import com.kuang.pojo.Books;

import java.util.List;

/**
 * @author SeRein
 */
public class BookServiceImpl implements BookService {

    //service 调dao层，组合Dao
    private BookMapper bookMapper;

    public void setBookMapper(BookMapper bookMapper) {
        this.bookMapper = bookMapper;
    }

    /**
     * 增加一本书
     *
     * @param books
     * @return
     */
    public int addBook(Books books) {
        return bookMapper.addBook(books);
    }

    /**
     * 删除一本书
     *
     * @param id
     * @return
     */
    public int deleteBookById(int id) {
        return bookMapper.deleteBookById(id);
    }

    /**
     * 更新一本书
     *
     * @param books
     * @return
     */
    public int updateBook(Books books) {
        return bookMapper.updateBook(books);
    }

    /**
     * 删除一本书
     *
     * @param id
     * @return
     */
    public Books queryBookById(int id) {
        return bookMapper.queryBookById(id);
    }

    /**
     * 查询所有的书
     *
     * @return
     */
    public List<Books> queryAllBooks() {
        return bookMapper.queryAllBooks();
    }
}
